package day07;

import java.util.Scanner;

public class CalAirPirce {
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        System.out.println("请输入机票票价");
        double price = scan.nextDouble();
        System.out.println("请输入月份");
        int month = scan.nextInt();
        System.out.println("请选择舱位：1.头等舱 2.商务舱 3.经济舱");
        int type = scan.nextInt();

        double finalPrice = calAirPirce(price, month, type);
        System.out.println("机票最终价格为" + finalPrice);
    }

    /*计算最终价格*/
    public static double calAirPirce(double price, int month, int type) {//定义三个形参
        double finalPrice = 0.0;//定义最后的价格为小数，0.0

        if (month < 1 || month > 12) {
            System.out.println("请重新输入");
            return -1;
        }
        if (type < 1 || type > 3) {
            System.out.println("舱位输入错误");
            return -1;
        }
        //打折
        if (month >= 5 && month <= 10) {
            switch (type) {
                case 1:
                    finalPrice = price * 0.9;
                    break;
                case 2:
                    finalPrice = price * 0.85;
                    break;
                case 3:
                    finalPrice = price * 0.8;
                    break;
            }
        } else {
            switch (type) {
                case 1:
                    finalPrice = price * 0.7;
                case 2:
                    finalPrice = price * 0.65;
                case 3:
                    finalPrice = price * 0.;
            }
        }
        return finalPrice;
    }
}